package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingPlan;
import com.zzyl.mapper.NursingPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingPlanServiceImpl implements NursingPlanService {

    @Autowired
    private NursingPlanMapper nursingPlanMapper;

    /**
     * 护理计划分页查询
     * @param name
     * @param status
     * @param pageSize
     * @param pageNum
     * @return
     */
    @Override
    public PageResponse paginatedQueries(String name, Integer status, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        NursingPlan nursingPlan = NursingPlan.builder().planName(name).status(status).build();
        Page<NursingPlanVo>page=nursingPlanMapper.list(nursingPlan);
        return PageResponse.of(page, NursingPlanVo.class);
    }

    /**
     * 获取所有护理计划
     * @return
     */
    @Override
    public List<NursingPlanVo> getAllQueries() {
        List<NursingPlanVo> allQueries=nursingPlanMapper.getAllQueries();
        return allQueries;
    }


}
